#include "OptimiseImage.h"


SDL_Surface* OptimiseImage::loadImage(string imagePath){
	
	//Temporary storage for the image that's loaded
    SDL_Surface* loadedImage = NULL;
    
    //The optimized image that will be used
    SDL_Surface* optimizedImage = NULL;

	//Load the image
    loadedImage = SDL_LoadBMP( imagePath.c_str() );

	//If nothing went wrong in loading the image
    if( loadedImage != NULL )
    {
        //Create an optimized image
        optimizedImage = SDL_DisplayFormat( loadedImage );
        
        //Free the old image
        SDL_FreeSurface( loadedImage );
    }

	//Return the optimized image
    return optimizedImage;
	
}
	
